package com.tlgen.orm.components.autoFill;

import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

@Component
public class DefaultAutoFillHandler implements AutoFillHandler {

    @Override
    public void save(Object entity) {
        setFieldValue(entity, "enable", 0);
        setFieldValue(entity, "createTime", LocalDateTime.now());
        setFieldValue(entity, "delFlag", 0);
    }
    @Override
    public void update(Object entity) {
        setFieldValue(entity, "updateTime", LocalDateTime.now());
    }


    @Override
    public void logicalDelete(Object entity) {
        setFieldValue(entity, "delFlag", 1);
    }

}